package br.edu.ufcg.lsd.wbis.ui.client.ui.loggedin.admin.uppermenu.user;

import br.edu.ufcg.lsd.wbis.ui.client.beans.UserInfo;
import br.edu.ufcg.lsd.wbis.ui.client.beans.UserInfo.UserPermission;
import br.edu.ufcg.lsd.wbis.ui.client.ui.management.InfoManager;

import com.gwtext.client.widgets.TabPanel;
import com.gwtext.client.widgets.ToolbarButton;
import com.gwtext.client.widgets.menu.Menu;

/**
 * @author Renato Miceli
 */
public class UserToolbarButton extends ToolbarButton {

	public UserToolbarButton(TabPanel centerPanel, InfoManager<UserInfo> infoManager) {

		this.setText("Users");

		final Menu usersMenu = new Menu();
		usersMenu.setShadow(true);
		usersMenu.setMinWidth(10);
		this.setMenu(usersMenu);

		if (infoManager.getInfo().getLevel() == UserPermission.ADMIN) {
			usersMenu.addItem(new AddUsersItem(centerPanel, infoManager));
			usersMenu.addItem(new ManageUsersItem(centerPanel, infoManager));
			usersMenu.addItem(new SearchUsersItem(centerPanel, infoManager));
		}
	}

}
